
// if (nickname!=""&&phone!=""&&password!=""&&code!=""&&nickname_msg==""&&phone_msg==""&&code_msg==""&&password_msg=="") {


function select(data) {
    $.post("/yuezhi/user/collect", {
        "uid": data,
    },)
}




function update(data) {
    console.log($("#nickname").val())

    let nickname = $("#nickname").val()
    let nickname_msg=$("#nickname_msg").text()
    let phone = $("#phone").val()
    let phone_msg=$("#nickname_msg").text()
    let password = $("#password").val()
    let password_msg=$("#nickname_msg").text()
    let birthday = $("#birthday").val()
    let school = $("#school").val()
    let name = $("#name").val()
    let education= $("#education").val()
    let adress = $("#adress").val()


    let birthday_msg=$("#birthday_msg").text()

    let education_msg= $("#education_msg").val()



    let sex= $("input[type='radio']:checked").val();
    // let education= $("option[type='radio']:checked").val();


    $("#education option:selected").text();

    console.log(nickname_msg)
    console.log(phone)
    console.log(phone_msg)
    console.log(password)
    console.log(password_msg)

    console.log(birthday)
    console.log(school)
    console.log(name)
    console.log(education)
    console.log(adress)

    console.log(sex)





    if (nickname!=""&&phone!=""&&password!=""&&nickname_msg==""&&phone_msg==""&&password_msg=="") {
        $.post("/yuezhi/user/update", {
            "usId": data,
            "usNickname": nickname,
            "usPhone":phone,
            "usPassword": password,
            "usBirthday": birthday,
            "usSchool": school,
            "usName": name,
            "usEducation": education,

            "usAdress": adress,

            "usAdress": adress,
            "usSex":sex

            // "usSex": man,
            // "usSex":woman
        }, function (data) {
            if (data.msg == "更新成功") {
                console.log("更新成功")
            }
        })
    }
}

$("#birthday").blur(function () {
    let birthday = $("#birthday").val();
    console.log(birthday)
    if(birthday ="") {
        $("#birthday_msg").text("请选择生日")

    }else {
        $("#birthday_msg").text("")
    }

})
$("#education").blur(function () {
    let education = $("#education").val();
    console.log(education)
    if(education !="") {
        $("#education_msg").text("")
    }else {
        $("#education_msg").text("请选择学历")
    }

})

$("#nickname").blur(function () {
    let username = $("#nickname").val()
    if (username != "") {
        if (!/^[a-zA-Z0-9_-]{4,16}$/.test(username)) {
            $("#nickname_msg").text("用户名不符合标准")
        }else{
            $("#nickname_msg").text("")
        }
    } else {
        $("#nickname_msg").text("用户名不能为空")
    }
    console.log(username);
})

$("#phone").blur(function (){
    let phone = $("#phone").val()
    if(phone !="") {
        if (!/^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$/.test(phone)) {
            $("#phone_msg").text("手机号不符合标准")
            return;
        } else {
            $("#phone_msg").text("")
        }
    }else{
        $("#phone_msg").text("手机号不能为空")
    }
})
$("#password").blur(function () {
    let password = $("#password").val();
    console.log(password)
    if(password !="") {
        if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,16}$/.test(password)) {
            $("#password_msg").text("至少8-16个字符，至少1个大写字母，1个小写字母和1个数字")
        } else {
            $("#password_msg").text("")
        }
    }else {
        $("#password_msg").text("密码不能为空")
    }

})


